package com.w4c.sim.render;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.font.FontRenderContext;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.List;

import javax.imageio.ImageIO;

class TextToImageDemo {

	private static drawLine(String txLine){

		// Image file name
		String fileName = "Image";

		// create a File Object
		File newFile = new File("d://" + fileName + ".jpeg");

		// create the font you wish to use
		Font font = new Font("Tahoma", Font.PLAIN, 11);

		// create the FontRenderContext object which helps us to measure the
		// text
		FontRenderContext frc = new FontRenderContext(null, true, true);

		// get the height and width of the text
		Rectangle2D bounds = font.getStringBounds(sampleText, frc);
		int w = (int) bounds.getWidth();
		int h = (int) bounds.getHeight();

		// create a BufferedImage object
		BufferedImage image = new BufferedImage(w, h,
				BufferedImage.TYPE_INT_RGB);

		// calling createGraphics() to get the Graphics2D
		Graphics2D g = image.createGraphics();

		// set color and other parameters
		g.setColor(Color.WHITE);
		g.fillRect(0, 0, w, h);
		g.setColor(Color.BLACK);
		g.setFont(font);

		g.drawString(sampleText, 10, 10);

		// releasing resources
		g.dispose();

		// creating the file
		ImageIO.write(image, "jpeg", newFile);
	}

	private static void getQuestionImage(String txQuestion){
		
		Font font = new Font("Tahoma", Font.PLAIN, 11);
		FontRenderContext frc = new FontRenderContext(null, true, true);
		
		List<String> txCodeLines = getTxCodeLines(txQuestion);
		
	}
	private static List<String> getTxCodeLines(String txQuestion){
		
	}	
	
	public static void main(String[] args) throws IOException {}
}